﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;

namespace Three.BookStore.OrderManagement
{
    public class SalesDeliveryOrders : ISalesDeliveryOrders
    {
        IRepository<SalesDeliveryOrder> _salesRep;

        public SalesDeliveryOrders(IRepository<SalesDeliveryOrder> salesRep)
        {
            _salesRep = salesRep;
        }

        public async Task<int> AddSalesDelivery(SalesDeliveryOrder sales)
        {
            var entity = await _salesRep.InsertAsync(sales);
            return entity.Id;
        } 

        public async Task<int> DELSalesDelivery(int id)
        {
            await _salesRep.DeleteAsync(x=>x.Id==id);
            return id;
        }

        public async Task<List<SalesDeliveryOrder>> ShowSalesDelivery()
        {
            return await _salesRep.GetListAsync();
        }

        public async Task<int> UpdateSalesDelivery(int id)
        {
            var entity = await _salesRep.GetAsync(x => x.Id == id);
            await _salesRep.UpdateAsync(entity);
            return id;
        }
         
    }
}
